package ex2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/10 13:09
 * @DESCRIBE
 */
public class MapDemo {
    public static void main(String[] args) {
//        Map<Integer, List<double>> map = null;
        Map<String,String> dic = new HashMap<>();

        //增
        dic.put("name","zhangsan");
        dic.put("age","18");

        //查
//        System.out.println(dic.containsKey("name"));//true
//        System.out.println(dic.containsValue("17"));//false
//        System.out.println(dic.get("age"));//18
//        System.out.println(dic.get("sex"));//null

        //改
        dic.put("name","lisi");//lisi

        //遍历1
        for (String key :dic.keySet()) {
            System.out.println(key+":"+dic.get(key));
        }
        //遍历2
        System.out.println(dic.entrySet());
        for (Map.Entry<String,String> entry : dic.entrySet()){
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }


    }
}
